<!-- 
macro是Jinja2宏
pagination_widget是宏名称
pagination是传递过来的值
endpoint这里表示的是路由名称
-->
{% macro pagination_widget(pagination,endpoint) %}
<!-- 分页效果1 -->
<ul class='pagination'>
    <li {% if not pagination.has_prev %} class="disabled"{% endif %}>
        <a href="{% if pagination.has_prev %}{{ url_for(endpoint, page=pagination.prev_num, **kwargs) }}{% else %}#{% endif %}">&laquo;</a>
    </li>
    {% for p in pagination.iter_pages() %}
        {% if p %}
            {% if p == pagination.page %}
                <li class="active">
                    <a href="{{ url_for(endpoint,page=p,**kwargs) }}">{{p}}</a>
                </li>
            {% else %}
                <li>
                    <a href="{{ url_for(endpoint,page=p,**kwargs) }}">{{p}}</a>
                </li>
            {% endif %}
        {% else %}
            <li class="disabled">
                <a href="#">&hellip;</a>
            </li>
        {% endif %}
    {% endfor %}
    <li {% if not pagination.has_next %} class="disabled"{% endif %}>
        <a href="{% if pagination.has_next %}{{ url_for(endpoint, page=pagination.next_num, **kwargs) }}{% else %}#{% endif %}">&raquo;</a>
    </li>
</ul>


<!-- 分页效果2 -->
<!-- <div>
    <ul class='pagination'>
        <li><a href="{{url_for(endpoint,page=1,**kwargs)}}">第一页</a></li>
        <li {% if not pagination.has_prev %} class="disabled"{% endif %}>
            <a href="{% if pagination.has_prev %}{{ url_for(endpoint, page=pagination.prev_num, **kwargs) }}{% else %}#{% endif %}">上一页</a>
        </li>


        
        {% for p in pagination.iter_pages(left_edge=0,left_current=5,right_current=5,right_edge=0) %}
            {% if p %}
                {% if p == pagination.page %}
                    <li class="active">
                        <a href="{{ url_for(endpoint,page=p,**kwargs) }}">{{p}}</a>
                    </li>
                {% else %}
                    <li>
                        <a href="{{ url_for(endpoint,page=p,**kwargs) }}">{{p}}</a>
                    </li>
                {% endif %}
            {% endif %}
        {% endfor %}

        <li {% if not pagination.has_next %} class="disabled"{% endif %}>
            <a href="{% if pagination.has_next %}{{ url_for(endpoint, page=pagination.next_num, **kwargs) }}{% else %}#{% endif %}">下一页</a></li>
        <li><a href="{{url_for(endpoint,page=pagination.pages,**kwargs)}}">最后一页</a></li>
    </ul>
</div> -->

{% endmacro %}